/***************************************************************************
 *   Copyright (C) 2005 by xihe                                            *
 *   xihels@163.com							   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#include "FriendInfo.h"
#include "CodeConverter.h"

extern CodeConverter g2u;


FriendInfo::FriendInfo(uint32_t _uid, uint8_t _status):
    BuddyInfo(_uid, false),
    ip(0x00000000),
    port(0x0000),
    face(1),
    age(0),
    group(0),
    sex(QQ_FRIEND_GENDER_GG),
    status(_status)
{
    bzero(&common, sizeof (common));
    bzero(&extend, sizeof (extend));
}

FriendInfo::FriendInfo(const QQGroupFriend& rhs) :
    BuddyInfo(rhs.uid, false),
    ip(0x00000000),
    port(0x0000),
    face(1),
    age(0),
    group(rhs.group / 4),
    sex(QQ_FRIEND_GENDER_GG),
    status(QQ_FRIEND_STATUS_OFFLINE)
{
    bzero(&common, sizeof (common));
    bzero(&extend, sizeof (extend));
}

FriendInfo::FriendInfo(const QQBuddy& rhs) : 
    BuddyInfo(rhs.uid, g2u.convert(rhs.nickname), false),
    face(rhs.face / 3),
    age(rhs.age),
    sex(rhs.sex),
    common(rhs.common),
    extend(rhs.extend),
    ip(0x00000000),
    port(0x0000),
    group(0),
    status(QQ_FRIEND_STATUS_OFFLINE)
{

}

FriendInfo::FriendInfo(const QQBuddyStatus& rhs) :
    BuddyInfo(rhs.uid, false),
    ip(rhs.ip),
    port(rhs.port),
    status(rhs.status),
    face(1),
    age(0),
    group(0),
    sex(QQ_FRIEND_GENDER_GG)
{
    bzero(&common, sizeof (common));
    bzero(&extend, sizeof (extend));
}
FriendInfo& FriendInfo::operator = (const QQBuddy& rhs) 
{ 
    nickname = g2u.convert(rhs.nickname);
    //nickname	= rhs.nickname;
    //uid	= rhs.uid;
    face	= rhs.face / 3;
    age		= rhs.age;
    sex		= rhs.sex;
    common	= rhs.common;
    extend	= rhs.extend;
    return *this;
}

FriendInfo& FriendInfo::operator = (const QQBuddyStatus& rhs)
{
    //uid  = rhs.uid;
    ip	   = rhs.ip;
    port   = rhs.port;
    status = rhs.status;

    return *this;
}


